<?php
include ("header.php");
if ($admin==1) { 
?>
<form action="addnews.php" method="post" name=add>
Заголовок:<br /> <input type="text" name="subject" maxlength="50" size="50" /><br />
Новость:<br />	<textarea name="news" maxlength="65535" rows="15" cols="50"></textarea><br />
<input type="checkbox" name="hide" />Скрыть<br />
<input type="submit" value="Добавить новость">
</form>
<?php

mysql_query ("CREATE TABLE IF NOT EXISTS `news_table` (
`id_news` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`subject_news` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`text_news` VARCHAR( 65535 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`hide_news` int(1) NOT NULL  default '0',
`date_news` TIMESTAMP NOT NULL
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;") or die(mysql_error());


if (!empty($_POST['news']) && !empty($_POST['subject'])) {
echo 'Последний ввод:';
echo '<br>';
$subject = mysql_real_escape_string($_POST['subject']);
$news = mysql_real_escape_string($_POST['news']);
echo $subject;
echo '<br>';
echo $news;
echo '<br>';
if (isset($_POST['hide'])) {$hide='1';} else {$hide='0';};
echo $hide;
mysql_query ("INSERT INTO news_table VALUES (0  ,'$subject','$news','$hide',NULL)") or die(mysql_error());
}
else {echo "Не введена новость!.<br> Пожалуйста, введите новость<br><br>";};
/*mysql_query ("DELETE FROM news WHERE id=1") or die(mysql_error());*/
 include ("footer.php");
}?>